package com.qtu.util;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * 缓存工具类
 */
public class CacheUtil {
    //定义 Jackson对象
    private static ObjectMapper mapper = new ObjectMapper();

    //LinkedHashMap 转对象
    public static <T> Object linkedHashMapToObject(Object obj,Class<T> c){
        try {
            String json = mapper.writeValueAsString(obj);
            T t = mapper.readValue(json,c);
            return t;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
